<?php echo $header; ?>
<div id="content">
  <div class="breadcrumb">
    <?php foreach ($breadcrumbs as $breadcrumb) { ?>
    <?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
    <?php } ?>
  </div>
  <?php if ($error_warning) { ?>
  <div class="warning"><?php echo $error_warning; ?></div>
  <?php } ?>
  <?php if ($success) { ?>
  <div class="success"><?php echo $success; ?></div>
  <?php } ?>
  <div class="box">
    <div class="heading">
      <h1><img src="view/image/customer.png" alt="" /> <?php echo $heading_title; ?></h1>
      <div class="buttons"></div>
    </div>
    <div class="content">
      <form action="" method="post" enctype="multipart/form-data" id="form">
        <table class="list">
          <thead>
            <tr>
              <td class="left"><?php if ($sort == 'name') { ?>
                <a href="<?php echo $sort_name; ?>" class="<?php echo strtolower($order); ?>"><?php echo $column_name; ?></a>
                <?php } else { ?>
                <a href="<?php echo $sort_name; ?>"><?php echo $column_name; ?></a>
                <?php } ?></td>
              <td class="left"><?php if ($sort == 'c.email') { ?>
                <a href="<?php echo $sort_email; ?>" class="<?php echo strtolower($order); ?>"><?php echo $column_email; ?></a>
                <?php } else { ?>
                <a href="<?php echo $sort_email; ?>"><?php echo $column_email; ?></a>
                <?php } ?></td>
              <td class="left"><?php echo $column_newsletter; ?></td>
              <td class="left"><?php echo $column_point; ?></td>
              <td class="left"><?php if ($sort == 'customer_grade') { ?>
                <a href="<?php echo $sort_customer_grade; ?>" class="<?php echo strtolower($order); ?>"><?php echo $column_customer_grade; ?></a>
                <?php } else { ?>
                <a href="<?php echo $sort_customer_grade; ?>"><?php echo $column_customer_grade; ?></a>
                <?php } ?></td>
              <td class="left"><?php echo $column_date_added; ?></td>
              <td class="right"><?php echo $column_action; ?></td>
            </tr>
          </thead>
          <tbody>
            <tr class="filter">
              <td><input type="text" name="filter_name" value="<?php echo $filter_name; ?>" /></td>
              <td><input type="text" name="filter_email" value="<?php echo $filter_email; ?>" /></td>
              <td></td>
              <td></td>
              <td><select name="filter_customer_grade_id">
                  <option value="-1">--</option>
                  <?php foreach ($customer_grades as $customer_grade) { ?>
                  <?php if ($customer_grade['customer_grade_id'] == $filter_customer_grade_id) { ?>
                  <option value="<?php echo $customer_grade['customer_grade_id']; ?>" selected="selected"><?php echo $customer_grade['name']; ?></option>
                  <?php } else { ?>
                  <option value="<?php echo $customer_grade['customer_grade_id']; ?>"><?php echo $customer_grade['name']; ?></option>
                  <?php } ?>
                  <?php } ?>
                </select></td>
              <td></td>
              <td align="right"><a onclick="filter();" class="button"><?php echo $button_filter; ?></a></td>
            </tr>
            <?php if ($customers) { ?>
            <?php foreach ($customers as $customer) { ?>
            <tr>
              <td class="left"><?php echo $customer['name']; ?></td>
              <td class="left"><?php echo $customer['email']; ?></td>
              <td class="left"><?php echo $customer['newsletter']; ?></td>
              <td class="left"><?php echo $customer['point']; ?></td>
              <td class="left"><?php echo $customer['grade_name']; ?></td>
              <td class="left"><?php echo $customer['date_added']; ?></td>
              <td class="right"><?php foreach ($customer['action'] as $action) { ?>
                [ <a href="<?php echo $action['href']; ?>"><?php echo $action['text']; ?></a> ]
                <?php } ?></td>
            </tr>
            <?php } ?>
            <?php } else { ?>
            <tr>
              <td class="center" colspan="7"><?php echo $text_no_results; ?></td>
            </tr>
            <?php } ?>
          </tbody>
        </table>
      </form>
      <div class="pagination"><?php echo $pagination; ?></div>
    </div>
  </div>
</div>
<script type="text/javascript"><!--
function filter() {
	url = 'index.php?route=customer/customer&token=<?php echo $token; ?>';
	var filter_name = $('input[name=\'filter_name\']').attr('value');
	if (filter_name) {
		url += '&filter_name=' + encodeURIComponent(filter_name);
	}
	var filter_email = $('input[name=\'filter_email\']').attr('value');
	if (filter_email) {
		url += '&filter_email=' + encodeURIComponent(filter_email);
	}
	var filter_customer_grade_id = $('select[name=\'filter_customer_grade_id\']').attr('value');
	if (filter_customer_grade_id != '-1') {
		url += '&filter_customer_grade_id=' + encodeURIComponent(filter_customer_grade_id);
	}	
	location = url;
}
//--></script>
<?php echo $footer; ?> 